package com.wsq.retrofitdemo.retrofit;

import android.util.Log;

import java.io.IOException;

import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 * Date:2021/9/2
 * Time:15:12
 * author:wushengqi
 */
public class LoggerInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Request request = chain.request();
        Headers headers = request.headers();
        Log.e("okhttp headers:", headers.toString());

        Response response;
        try {
            response = chain.proceed(request);
            ResponseBody responseBody = response.body();

            Log.e("okhttp response:", new String(responseBody.bytes()));
            return response;
        } catch (Exception e) {
            e.printStackTrace();
        }



        return null;
    }
}
